import dayjs from 'dayjs'
export default {
  props: {
    data: {
      type: Array,
      default: () => {
        return []
      }
    },
    loading: {
      type: Boolean,
      default: false
    },
    load: {
      type: Function,
      default: () => { }
    },
    total: {
      type: Number,
      default: 0
    },
    filterAnd: {
      type: Array,
      default: () => {
        return []
      }
    },
    currentPage: {
      type: Number,
      default: 1
    },
    size: {
      type: Number,
      default: 12
    }
  },
  data () {
    return {
      page: this.currentPage,
      perPage: this.size,
      nodetypeOpts: []
    }
  },
  methods: {
    refreshList () {
      this.$emit('load', this.page, this.perPage)
    },
    handlerLoad (page, size) {
      this.perPage = size
      this.page = page
      this.$emit('load', page, size)
    },
    formatDate (val, label) {
      return val ? dayjs.unix(val).format(label || 'YYYY-MM-DD HH:mm:ss') : ''
    },
    formatDate1 (val, label) {
      return val ? dayjs(val).format(label || 'YYYY-MM-DD HH:mm:ss') : ''
    },
    toPath (path, isNewTab = false) {
      if (path.indexOf('http') >= 0) {
        window.open(path, '_blank')
      }
      if (!isNewTab) {
        this.$router.push(path)
        return
      }
      const routeData = this.$router.resolve({
        path
      })
      window.open(routeData.href, '_blank')
    },
    parseFloatNum (v) {
      if (!v) return v
      return parseFloat(v / 100)
    }
  }
}
